/**
 * @Author 韦建韩
 * @Date 2022/5/19
 */
package com.example.devops.service.impl;

import com.example.devops.dao.PublishHistoryMapper;
import com.example.devops.entity.common.Result;
import com.example.devops.entity.pojo.PublishHistory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service
public class PublishHistoryService {
    @Autowired
    PublishHistoryMapper publishHistoryMapper;

    public Result getPublishHistory(){
        List<PublishHistory> publishHistories = publishHistoryMapper.getPublishHistory();
        SimpleDateFormat  simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日HH:mm:ss");
        Date date = new Date();

        publishHistories.forEach(x->{
            date.setTime(x.getPublishDate());
            x.setDateString(simpleDateFormat.format(date));
        });
        return Result.doCreate(publishHistories);
    }


}
